﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using MongoDB.Driver;
using Sustainalytics.ClientDW.Entities;
using Sustainalytics.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace Sustainalytics.ClientDW.DataAccessLayer.Tests
{
    [TestClass]
    public class ClientDWGlobalCompactRepositoryTest
    {
        private const string ConnectionString = "mongodb://localhost:27017/ClientDWTests";
        private IMongoDatabase _database;
        private IClientDWGlobalCompactRepository _repository;

        private GCPillarTemplate _pillarTemplate1;
        private GCPillarTemplate _pillarTemplate2;
        private GCPillarTemplate _pillarTemplate3;
        private GCPillarTemplate _pillarTemplate4;

        private GCPrincipleTemplate _principleTemplate1;
        private GCPrincipleTemplate _principleTemplate2;
        private GCPrincipleTemplate _principleTemplate3;
        private GCPrincipleTemplate _principleTemplate4;
        private GCPrincipleTemplate _principleTemplate5;
        private GCPrincipleTemplate _principleTemplate6;
        private GCPrincipleTemplate _principleTemplate7;
        private GCPrincipleTemplate _principleTemplate8;

        private List<GCOverallCompanySummary> _overallCompanySummaryDocuments = new List<GCOverallCompanySummary>();
        private List<GCOverallCompanySummaryExtended> _overallCompanySummaryExtendedDocuments = new List<GCOverallCompanySummaryExtended>();
        private List<GCPrincipleSummary> _principleSummaryDocuments = new List<GCPrincipleSummary>();
        private List<GCPrincipleConclusion> _principleConclusionDocuments = new List<GCPrincipleConclusion>();
        private List<GCPrincipleEventIndicator> _principleEventIndicatorDocuments = new List<GCPrincipleEventIndicator>();
        private List<GCPrincipleEventIndicatorImpact> _principleEventIndicatorImpactDocuments = new List<GCPrincipleEventIndicatorImpact>();
        private List<GCPrincipleEventIndicatorManagement> _principleEventIndicatorManagementDocuments = new List<GCPrincipleEventIndicatorManagement>();

        private void SetupFake_Common()
        {
            #region GCPillarTemplate

            _pillarTemplate1 = new GCPillarTemplate { Id = 1, Name = "Human Rights" };
            _pillarTemplate2 = new GCPillarTemplate { Id = 2, Name = "Labour Rights" };
            _pillarTemplate3 = new GCPillarTemplate { Id = 3, Name = "Environment" };
            _pillarTemplate4 = new GCPillarTemplate { Id = 4, Name = "Business Ethics" };

            #endregion

            #region GCPrincipleTemplate

            _principleTemplate1 = new GCPrincipleTemplate { Id = 1, Name = "Global Compact Principle 1", Pillar = _pillarTemplate1, Description = "Businesses should support and respect the protection of internationally proclaimed human rights." };
            _principleTemplate2 = new GCPrincipleTemplate { Id = 2, Name = "Global Compact Principle 2", Pillar = _pillarTemplate1, Description = "Businesses should make sure that they are not complicit in human rights abuses." };
            _principleTemplate3 = new GCPrincipleTemplate { Id = 3, Name = "Global Compact Principle 3", Pillar = _pillarTemplate2, Description = "Businesses should uphold the freedom of association and the effective recognition of the right to collective bargaining." };
            _principleTemplate4 = new GCPrincipleTemplate { Id = 4, Name = "Global Compact Principle 4", Pillar = _pillarTemplate2, Description = "Businesses should uphold the elimination of all forms of forced and compulsory labour." };
            _principleTemplate5 = new GCPrincipleTemplate { Id = 5, Name = "Global Compact Principle 5", Pillar = _pillarTemplate2, Description = "Businesses should uphold the effective abolition of child labour." };
            _principleTemplate6 = new GCPrincipleTemplate { Id = 6, Name = "Global Compact Principle 6", Pillar = _pillarTemplate2, Description = "Businesses should uphold the elimination of discrimination in respect of employment and occupation." };
            _principleTemplate7 = new GCPrincipleTemplate { Id = 7, Name = "Global Compact Principle 7", Pillar = _pillarTemplate3, Description = "Businesses should support a precautionary approach to environmental challenges." };
            _principleTemplate8 = new GCPrincipleTemplate { Id = 8, Name = "Global Compact Principle 10", Pillar = _pillarTemplate4, Description = "Businesses should work against corruption in all its forms, including extortion and bribery." };

            #endregion
        }

        private void SetupFake_Company_Compliant()
        {
            #region GCCompanyProfile

            var _companyProfile2 = new GCCompanyProfile
            {
                // Agilent Technologies
                Id = Guid.Parse("a43f7991-eedd-4729-8b1f-78ae9a190459"),
                Country = "Argentina",
                Industry = "IndustryY",
                MainExchange = "KLSE",
                MainTicker = "A&M",
                MainIsin = "MYL5959OO001",
                MainSedol = "B05KKM6",
                Name = "A & M Realty Berhad",
                NameLowercase = "a & m realty berhad"
            };

            #endregion

            #region GCOverallCompanySummary

            var _overallCompanySummary = new GCOverallCompanySummary
            {
                Id = Guid.NewGuid(),
                CompanyProfile = _companyProfile2,
                LastUpdated = DateTime.UtcNow.AddDays(-14),
                GCSignatorySince = DateTime.UtcNow.AddDays(-104),
                OverallCompanyAssessment = GCAssessment.Compliant,
                OverallCompanyAssessmentEffectiveSince = DateTime.Now.AddDays(-100),
                UniverseIds = new List<int> { 1, 2, 3, 4, 5 }
            };

            _overallCompanySummaryDocuments.AddRange(new List<GCOverallCompanySummary>
            {
                _overallCompanySummary
            });

            #endregion

            #region GCOverallCompanySummaryExtended

            var _overallCompanySummaryExtended = new GCOverallCompanySummaryExtended
            {
                Id = _overallCompanySummary.Id,
                CompanyProfile = _overallCompanySummary.CompanyProfile,
                LastUpdated = _overallCompanySummary.LastUpdated,
                GCSignatorySince = _overallCompanySummary.GCSignatorySince,
                OverallCompanyAssessment = _overallCompanySummary.OverallCompanyAssessment,
                OverallCompanyAssessmentEffectiveSince = _overallCompanySummary.OverallCompanyAssessmentEffectiveSince,
                NonCompliantPrinciples = new List<GCPrincipleTemplate>(),
                NonCompliantSince = null,
                WatchListPrinciples = new List<GCPrincipleTemplate>(),
                WatchListSince = null,
                UniverseIds = new List<int> { 1, 2, 3, 4, 5 }
            };

            _overallCompanySummaryExtendedDocuments.AddRange(new List<GCOverallCompanySummaryExtended>
            {
                _overallCompanySummaryExtended
            });

            #endregion
        }

        private void SetupFake_Company_Watchlist()
        {
            #region GCCompanyProfile

            var _companyProfile3 = new GCCompanyProfile
            {
                Id = Guid.Parse("469a61a9-3ff0-4d29-b509-04905b25b6e9"),
                Country = "Canada",
                Industry = "IndustryZ",
                MainExchange = "PSE",
                MainTicker = "BRN",
                MainIsin = "PHY000221069",
                MainSedol = "6147279",
                Name = "A Brown Company, Inc.",
                NameLowercase = "a brown company, inc."
            };

            #endregion

            #region GCOverallCompanySummary

            var _overallCompanySummary = new GCOverallCompanySummary
            {
                Id = Guid.NewGuid(),
                CompanyProfile = _companyProfile3,
                LastUpdated = DateTime.UtcNow.AddDays(-20),
                GCSignatorySince = DateTime.UtcNow.AddDays(-108),
                OverallCompanyAssessment = GCAssessment.Watchlist,
                OverallCompanyAssessmentEffectiveSince = DateTime.Now.AddDays(-20),
                UniverseIds = new List<int> { 1, 2, 3, 4, 5 }
            };

            _overallCompanySummaryDocuments.AddRange(new List<GCOverallCompanySummary>
            {
                _overallCompanySummary
            });

            #endregion

            #region GCOverallCompanySummaryExtended

            var _overallCompanySummaryExtended = new GCOverallCompanySummaryExtended
            {
                Id = _overallCompanySummary.Id,
                CompanyProfile = _overallCompanySummary.CompanyProfile,
                LastUpdated = _overallCompanySummary.LastUpdated,
                GCSignatorySince = _overallCompanySummary.GCSignatorySince,
                OverallCompanyAssessment = _overallCompanySummary.OverallCompanyAssessment,
                OverallCompanyAssessmentEffectiveSince = _overallCompanySummary.OverallCompanyAssessmentEffectiveSince,
                NonCompliantPrinciples = new List<GCPrincipleTemplate>(),
                NonCompliantSince = null,
                WatchListPrinciples = new List<GCPrincipleTemplate> { _principleTemplate5, _principleTemplate4, _principleTemplate1 },
                WatchListSince = DateTime.UtcNow.AddMonths(-15),
                UniverseIds = new List<int> { 1, 2, 3, 4, 5 }
            };

            _overallCompanySummaryExtendedDocuments.AddRange(new List<GCOverallCompanySummaryExtended>
            {
                _overallCompanySummaryExtended
            });

            #endregion

            #region GCPrincipleSummary

            var _principleSummary1 = new GCPrincipleSummary
            {
                Id = Guid.NewGuid(),
                CompanyId = _companyProfile3.Id,
                Issue = "Issue 555",
                Principle = _principleTemplate5,
                PrincipleAssessment = GCAssessment.Watchlist,
                PrincipleAssessmentEffectiveSince = DateTime.UtcNow.AddMonths(-4)
            };

            var _principleSummary2 = new GCPrincipleSummary
            {
                Id = Guid.NewGuid(),
                CompanyId = _companyProfile3.Id,
                Issue = "Issue 444",
                Principle = _principleTemplate4,
                PrincipleAssessment = GCAssessment.Watchlist,
                PrincipleAssessmentEffectiveSince = DateTime.UtcNow.AddMonths(-4)
            };

            var _principleSummary3 = new GCPrincipleSummary
            {
                Id = Guid.NewGuid(),
                CompanyId = _companyProfile3.Id,
                Issue = "Issue 111",
                Principle = _principleTemplate1,
                PrincipleAssessment = GCAssessment.Watchlist,
                PrincipleAssessmentEffectiveSince = DateTime.UtcNow.AddMonths(-4)
            };

            _principleSummaryDocuments.AddRange(new List<GCPrincipleSummary>
            {
                _principleSummary1,
                _principleSummary2,
                _principleSummary3
            });

            #endregion

            #region GCPrincipleConclusion

            var _principleConclusion1 = new GCPrincipleConclusion
            {
                Id = _principleSummary1.Id,
                AssessmentComments = new List<string>
                {
                    "Assessment Comment 1",
                    "Assessment Comment 2",
                    "Assessment Comment 3",
                    "Assessment Comment 4",
                    "Assessment Comment 5",
                    "Assessment Comment 6"
                },
                AssessmentSummaryAndConclusionIntroductionSentence = "Conclusion Introduction Sentence ... and some info."
            };

            var _principleConclusion2 = new GCPrincipleConclusion
            {
                Id = _principleSummary2.Id,
                AssessmentComments = new List<string>
                {
                    "Assessment Comment 1",
                    "Assessment Comment 2",
                    "Assessment Comment 3",
                    "Assessment Comment 4",
                },
                AssessmentSummaryAndConclusionIntroductionSentence = "Conclusion Introduction Sentence ... and some info."
            };

            var _principleConclusion3 = new GCPrincipleConclusion
            {
                Id = _principleSummary3.Id,
                AssessmentComments = new List<string>
                {
                    "Assessment Comment 3",
                    "Assessment Comment 4",
                    "Assessment Comment 5",
                    "Assessment Comment 6"
                },
                AssessmentSummaryAndConclusionIntroductionSentence = "Conclusion Introduction Sentence ... and some info."
            };

            _principleConclusionDocuments.AddRange(new List<GCPrincipleConclusion>
            {
                _principleConclusion1,
                _principleConclusion2,
                _principleConclusion3
            });

            #endregion

            #region GCPrincipleEventIndicator

            var _principleEventIndicator1 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.Watchlist,
                PrincipleSummaryId = _principleSummary1.Id,
                IssueType = "Issue Type ... and other info."
            };

            var _principleEventIndicator2 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.Watchlist,
                PrincipleSummaryId = _principleSummary1.Id,
                IssueType = "Issue Type ... and other info."
            };

            var _principleEventIndicator3 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.Watchlist,
                PrincipleSummaryId = _principleSummary1.Id,
                IssueType = "Issue Type ... and other info."
            };

            var _principleEventIndicator4 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.Watchlist,
                PrincipleSummaryId = _principleSummary2.Id,
                IssueType = "Issue Type ... and other info."
            };

            var _principleEventIndicator5 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.Watchlist,
                PrincipleSummaryId = _principleSummary3.Id,
                IssueType = "Issue Type ... and other info."
            };

            _principleEventIndicatorDocuments.AddRange(new List<GCPrincipleEventIndicator>
            {
                _principleEventIndicator1,
                _principleEventIndicator2,
                _principleEventIndicator3,
                _principleEventIndicator4,
                _principleEventIndicator5
            });

            #endregion

            #region GCPrincipleEventIndicatorImpact

            var _principleEventIndicatorImpact1 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact1.LoadFrom(_principleEventIndicator1);
            _principleEventIndicatorImpact1.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact1.ImpactComments = new List<string>
            {
                "Impact Comment 1",
                "Impact Comment 2",
                "Impact Comment 3",
                "Impact Comment 4",
                "Impact Comment 5"
            };

            var _principleEventIndicatorImpact2 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact2.LoadFrom(_principleEventIndicator2);
            _principleEventIndicatorImpact2.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact2.ImpactComments = new List<string>
            {
                "Impact Comment 1",
                "Impact Comment 5"
            };

            var _principleEventIndicatorImpact3 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact3.LoadFrom(_principleEventIndicator3);
            _principleEventIndicatorImpact3.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact3.ImpactComments = new List<string>
            {
                "Impact Comment 1",
                "Impact Comment 2",
                "Impact Comment 5"
            };

            var _principleEventIndicatorImpact4 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact4.LoadFrom(_principleEventIndicator4);
            _principleEventIndicatorImpact4.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact4.ImpactComments = new List<string>
            {
                "Impact Comment 3",
                "Impact Comment 4",
                "Impact Comment 5"
            };

            var _principleEventIndicatorImpact5 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact5.LoadFrom(_principleEventIndicator5);
            _principleEventIndicatorImpact5.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact5.ImpactComments = new List<string>
            {
                "Impact Comment 1",
                "Impact Comment 2",
                "Impact Comment 3"
            };

            _principleEventIndicatorImpactDocuments.AddRange(new List<GCPrincipleEventIndicatorImpact>
            {
                _principleEventIndicatorImpact1,
                _principleEventIndicatorImpact2,
                _principleEventIndicatorImpact3,
                _principleEventIndicatorImpact4,
                _principleEventIndicatorImpact5
            });

            #endregion

            #region GCPrincipleEventIndicatorManagement

            var _principleEventIndicatorManagement1 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement1.LoadFrom(_principleEventIndicator1);
            _principleEventIndicatorManagement1.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement1.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            var _principleEventIndicatorManagement2 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement2.LoadFrom(_principleEventIndicator2);
            _principleEventIndicatorManagement2.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement2.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            var _principleEventIndicatorManagement3 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement3.LoadFrom(_principleEventIndicator3);
            _principleEventIndicatorManagement3.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement3.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            var _principleEventIndicatorManagement4 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement4.LoadFrom(_principleEventIndicator4);
            _principleEventIndicatorManagement4.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement4.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            var _principleEventIndicatorManagement5 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement5.LoadFrom(_principleEventIndicator5);
            _principleEventIndicatorManagement5.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement5.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            _principleEventIndicatorManagementDocuments.AddRange(new List<GCPrincipleEventIndicatorManagement>
            {
                _principleEventIndicatorManagement1,
                _principleEventIndicatorManagement2,
                _principleEventIndicatorManagement3,
                _principleEventIndicatorManagement4,
                _principleEventIndicatorManagement5
            });

            #endregion
        }

        private void SetupFake_Company_NonCompliant()
        {
            #region GCCompanyProfile

            var _companyProfile1 = new GCCompanyProfile
            {
                // Agilent Technologies
                Id = Guid.Parse("f9b1054b-369b-45da-8595-4dbbe7e4bda4"),
                Country = "United States",
                Industry = "IndustryX",
                MainExchange = "NYSE",
                MainTicker = "A",
                MainIsin = "US00846U1016",
                MainSedol = "2520153",
                Name = "Agilent Technologies Inc.",
                NameLowercase = "agilent technologies inc."
            };

            #endregion

            #region GCOverallCompanySummary

            var _overallCompanySummary = new GCOverallCompanySummary
            {
                Id = Guid.NewGuid(),
                CompanyProfile = _companyProfile1,
                LastUpdated = DateTime.UtcNow.AddDays(-10),
                GCSignatorySince = DateTime.UtcNow.AddDays(-100),
                OverallCompanyAssessment = GCAssessment.NonCompliant,
                OverallCompanyAssessmentEffectiveSince = DateTime.Now.AddDays(-1),
                UniverseIds = new List<int> { 1, 2, 3, 4, 5 }
            };

            _overallCompanySummaryDocuments.AddRange(new List<GCOverallCompanySummary>
            {
                _overallCompanySummary
            });

            #endregion

            #region GCOverallCompanySummaryExtended

            var _overallCompanySummaryExtended = new GCOverallCompanySummaryExtended
            {
                Id = _overallCompanySummary.Id,
                CompanyProfile = _overallCompanySummary.CompanyProfile,
                LastUpdated = _overallCompanySummary.LastUpdated,
                GCSignatorySince = _overallCompanySummary.GCSignatorySince,
                OverallCompanyAssessment = _overallCompanySummary.OverallCompanyAssessment,
                OverallCompanyAssessmentEffectiveSince = _overallCompanySummary.OverallCompanyAssessmentEffectiveSince,
                NonCompliantPrinciples = new List<GCPrincipleTemplate> { _principleTemplate2, _principleTemplate3, _principleTemplate1 },
                NonCompliantSince = DateTime.UtcNow.AddMonths(-4),
                WatchListPrinciples = new List<GCPrincipleTemplate> { _principleTemplate5, _principleTemplate4 },
                WatchListSince = DateTime.UtcNow.AddMonths(-8),
                UniverseIds = new List<int> { 1, 2, 3, 4, 5 }
            };

            _overallCompanySummaryExtendedDocuments.AddRange(new List<GCOverallCompanySummaryExtended>
            {
                _overallCompanySummaryExtended
            });

            #endregion

            #region GCPrincipleSummary

            var _principleSummary1 = new GCPrincipleSummary
            {
                Id = Guid.NewGuid(),
                CompanyId = _companyProfile1.Id,
                Issue = "Issue 222",
                Principle = _principleTemplate2,
                PrincipleAssessment = GCAssessment.NonCompliant,
                PrincipleAssessmentEffectiveSince = DateTime.UtcNow.AddMonths(-4)
            };

            var _principleSummary2 = new GCPrincipleSummary
            {
                Id = Guid.NewGuid(),
                CompanyId = _companyProfile1.Id,
                Issue = "Issue 333",
                Principle = _principleTemplate3,
                PrincipleAssessment = GCAssessment.NonCompliant,
                PrincipleAssessmentEffectiveSince = DateTime.UtcNow.AddMonths(-4)
            };

            var _principleSummary3 = new GCPrincipleSummary
            {
                Id = Guid.NewGuid(),
                CompanyId = _companyProfile1.Id,
                Issue = "Issue 111",
                Principle = _principleTemplate1,
                PrincipleAssessment = GCAssessment.NonCompliant,
                PrincipleAssessmentEffectiveSince = DateTime.UtcNow.AddMonths(-4)
            };

            var _principleSummary4 = new GCPrincipleSummary
            {
                Id = Guid.NewGuid(),
                CompanyId = _companyProfile1.Id,
                Issue = "Issue 555",
                Principle = _principleTemplate5,
                PrincipleAssessment = GCAssessment.Watchlist,
                PrincipleAssessmentEffectiveSince = DateTime.UtcNow.AddMonths(-4)
            };

            var _principleSummary5 = new GCPrincipleSummary
            {
                Id = Guid.NewGuid(),
                CompanyId = _companyProfile1.Id,
                Issue = "Issue 444",
                Principle = _principleTemplate4,
                PrincipleAssessment = GCAssessment.Watchlist,
                PrincipleAssessmentEffectiveSince = DateTime.UtcNow.AddMonths(-4)
            };

            _principleSummaryDocuments.AddRange(new List<GCPrincipleSummary>
            {
                _principleSummary1,
                _principleSummary2,
                _principleSummary3,
                _principleSummary4,
                _principleSummary5
            });

            #endregion

            #region GCPrincipleConclusion

            var _principleConclusion1 = new GCPrincipleConclusion
            {
                Id = _principleSummary1.Id,
                AssessmentComments = new List<string>
                {
                    "Assessment Comment 1",
                    "Assessment Comment 2",
                    "Assessment Comment 3",
                    "Assessment Comment 4",
                    "Assessment Comment 5",
                    "Assessment Comment 6"
                },
                AssessmentSummaryAndConclusionIntroductionSentence = "Conclusion Introduction Sentence ... and some info."
            };

            var _principleConclusion2 = new GCPrincipleConclusion
            {
                Id = _principleSummary2.Id,
                AssessmentComments = new List<string>
                {
                    "Assessment Comment 1",
                    "Assessment Comment 2",
                    "Assessment Comment 3",
                    "Assessment Comment 4",
                },
                AssessmentSummaryAndConclusionIntroductionSentence = "Conclusion Introduction Sentence ... and some info."
            };

            var _principleConclusion3 = new GCPrincipleConclusion
            {
                Id = _principleSummary3.Id,
                AssessmentComments = new List<string>
                {
                    "Assessment Comment 3",
                    "Assessment Comment 4",
                    "Assessment Comment 5",
                    "Assessment Comment 6"
                },
                AssessmentSummaryAndConclusionIntroductionSentence = "Conclusion Introduction Sentence ... and some info."
            };

            var _principleConclusion4 = new GCPrincipleConclusion
            {
                Id = _principleSummary4.Id,
                AssessmentComments = new List<string>
                {
                    "Assessment Comment 1",
                    "Assessment Comment 2",
                    "Assessment Comment 5",
                    "Assessment Comment 6"
                },
                AssessmentSummaryAndConclusionIntroductionSentence = "Conclusion Introduction Sentence ... and some info."
            };

            var _principleConclusion5 = new GCPrincipleConclusion
            {
                Id = _principleSummary5.Id,
                AssessmentComments = new List<string>
                {
                    "Assessment Comment 1"
                },
                AssessmentSummaryAndConclusionIntroductionSentence = "Conclusion Introduction Sentence ... and some info."
            };

            _principleConclusionDocuments.AddRange(new List<GCPrincipleConclusion>
            {
                _principleConclusion1,
                _principleConclusion2,
                _principleConclusion3,
                _principleConclusion4,
                _principleConclusion5
            });

            #endregion

            #region GCPrincipleEventIndicator

            var _principleEventIndicator1 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.NonCompliant,
                PrincipleSummaryId = _principleSummary2.Id,
                IssueType = "Issue Type ... and other info."
            };

            var _principleEventIndicator2 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.NonCompliant,
                PrincipleSummaryId = _principleSummary3.Id,
                IssueType = "Issue Type ... and other info."
            };

            var _principleEventIndicator3 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.NonCompliant,
                PrincipleSummaryId = _principleSummary1.Id,
                IssueType = "Issue Type ... and other info."
            };

            var _principleEventIndicator4 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.Watchlist,
                PrincipleSummaryId = _principleSummary5.Id,
                IssueType = "Issue Type ... and other info."
            };

            var _principleEventIndicator5 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.Watchlist,
                PrincipleSummaryId = _principleSummary4.Id,
                IssueType = "Issue Type ... and other info."
            };

            _principleEventIndicatorDocuments.AddRange(new List<GCPrincipleEventIndicator>
            {
                _principleEventIndicator1,
                _principleEventIndicator2,
                _principleEventIndicator3,
                _principleEventIndicator4,
                _principleEventIndicator5
            });

            #endregion

            #region GCPrincipleEventIndicatorImpact

            var _principleEventIndicatorImpact1 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact1.LoadFrom(_principleEventIndicator1);
            _principleEventIndicatorImpact1.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact1.ImpactComments = new List<string>
            {
                "Impact Comment 1",
                "Impact Comment 2",
                "Impact Comment 3",
                "Impact Comment 4",
                "Impact Comment 5"
            };

            var _principleEventIndicatorImpact2 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact2.LoadFrom(_principleEventIndicator2);
            _principleEventIndicatorImpact2.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact2.ImpactComments = new List<string>
            {
                "Impact Comment 1",
                "Impact Comment 5"
            };

            var _principleEventIndicatorImpact3 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact3.LoadFrom(_principleEventIndicator3);
            _principleEventIndicatorImpact3.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact3.ImpactComments = new List<string>
            {
                "Impact Comment 1",
                "Impact Comment 2",
                "Impact Comment 5"
            };

            var _principleEventIndicatorImpact4 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact4.LoadFrom(_principleEventIndicator4);
            _principleEventIndicatorImpact4.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact4.ImpactComments = new List<string>
            {
                "Impact Comment 3",
                "Impact Comment 4",
                "Impact Comment 5"
            };

            var _principleEventIndicatorImpact5 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact5.LoadFrom(_principleEventIndicator5);
            _principleEventIndicatorImpact5.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact5.ImpactComments = new List<string>
            {
                "Impact Comment 1",
                "Impact Comment 2",
                "Impact Comment 3"
            };

            _principleEventIndicatorImpactDocuments.AddRange(new List<GCPrincipleEventIndicatorImpact>
            {
                _principleEventIndicatorImpact1,
                _principleEventIndicatorImpact2,
                _principleEventIndicatorImpact3,
                _principleEventIndicatorImpact4,
                _principleEventIndicatorImpact5
            });

            #endregion

            #region GCPrincipleEventIndicatorManagement

            var _principleEventIndicatorManagement1 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement1.LoadFrom(_principleEventIndicator1);
            _principleEventIndicatorManagement1.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement1.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            var _principleEventIndicatorManagement2 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement2.LoadFrom(_principleEventIndicator2);
            _principleEventIndicatorManagement2.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement2.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            var _principleEventIndicatorManagement3 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement3.LoadFrom(_principleEventIndicator3);
            _principleEventIndicatorManagement3.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement3.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            var _principleEventIndicatorManagement4 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement4.LoadFrom(_principleEventIndicator4);
            _principleEventIndicatorManagement4.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement4.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            var _principleEventIndicatorManagement5 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement5.LoadFrom(_principleEventIndicator5);
            _principleEventIndicatorManagement5.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement5.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            _principleEventIndicatorManagementDocuments.AddRange(new List<GCPrincipleEventIndicatorManagement>
            {
                _principleEventIndicatorManagement1,
                _principleEventIndicatorManagement2,
                _principleEventIndicatorManagement3,
                _principleEventIndicatorManagement4,
                _principleEventIndicatorManagement5
            });

            #endregion
        }

        private void SetupFake_Company_NonCompliant_NoWatchlistIndicators()
        {
            #region GCCompanyProfile

            var _companyProfile4 = new GCCompanyProfile
            {
                // Agilent Technologies
                Id = Guid.Parse("b43ba66f-7060-454e-92a6-6db04c3d57f9"),
                Country = "Cuba",
                Industry = "IndustryA",
                MainExchange = "TSE",
                MainTicker = "7745",
                MainIsin = "JP3160130005",
                MainSedol = "6601388",
                Name = "A&D Company, Limited",
                NameLowercase = "a&d company, limited"
            };

            #endregion

            #region GCOverallCompanySummary

            var _overallCompanySummary = new GCOverallCompanySummary
            {
                Id = Guid.NewGuid(),
                CompanyProfile = _companyProfile4,
                LastUpdated = DateTime.UtcNow.AddDays(-10),
                GCSignatorySince = DateTime.UtcNow.AddDays(-100),
                OverallCompanyAssessment = GCAssessment.NonCompliant,
                OverallCompanyAssessmentEffectiveSince = DateTime.Now.AddDays(-1),
                UniverseIds = new List<int> { 1, 2, 3, 4, 5 }
            };

            _overallCompanySummaryDocuments.AddRange(new List<GCOverallCompanySummary>
            {
                _overallCompanySummary
            });

            #endregion

            #region GCOverallCompanySummaryExtended

            var _overallCompanySummaryExtended = new GCOverallCompanySummaryExtended
            {
                Id = _overallCompanySummary.Id,
                CompanyProfile = _overallCompanySummary.CompanyProfile,
                LastUpdated = _overallCompanySummary.LastUpdated,
                GCSignatorySince = _overallCompanySummary.GCSignatorySince,
                OverallCompanyAssessment = _overallCompanySummary.OverallCompanyAssessment,
                OverallCompanyAssessmentEffectiveSince = _overallCompanySummary.OverallCompanyAssessmentEffectiveSince,
                NonCompliantPrinciples = new List<GCPrincipleTemplate> { _principleTemplate2, _principleTemplate3, _principleTemplate1 },
                NonCompliantSince = DateTime.UtcNow.AddMonths(-4),
                WatchListPrinciples = new List<GCPrincipleTemplate>(),
                WatchListSince = null,
                UniverseIds = new List<int> { 1, 2, 3, 4, 5 }
            };

            _overallCompanySummaryExtendedDocuments.AddRange(new List<GCOverallCompanySummaryExtended>
            {
                _overallCompanySummaryExtended
            });

            #endregion

            #region GCPrincipleSummary

            var _principleSummary1 = new GCPrincipleSummary
            {
                Id = Guid.NewGuid(),
                CompanyId = _companyProfile4.Id,
                Issue = "Issue 222",
                Principle = _principleTemplate2,
                PrincipleAssessment = GCAssessment.NonCompliant,
                PrincipleAssessmentEffectiveSince = DateTime.UtcNow.AddMonths(-4)
            };

            var _principleSummary2 = new GCPrincipleSummary
            {
                Id = Guid.NewGuid(),
                CompanyId = _companyProfile4.Id,
                Issue = "Issue 333",
                Principle = _principleTemplate3,
                PrincipleAssessment = GCAssessment.NonCompliant,
                PrincipleAssessmentEffectiveSince = DateTime.UtcNow.AddMonths(-4)
            };

            var _principleSummary3 = new GCPrincipleSummary
            {
                Id = Guid.NewGuid(),
                CompanyId = _companyProfile4.Id,
                Issue = "Issue 111",
                Principle = _principleTemplate1,
                PrincipleAssessment = GCAssessment.NonCompliant,
                PrincipleAssessmentEffectiveSince = DateTime.UtcNow.AddMonths(-4)
            };

            _principleSummaryDocuments.AddRange(new List<GCPrincipleSummary>
            {
                _principleSummary1,
                _principleSummary2,
                _principleSummary3
            });

            #endregion

            #region GCPrincipleConclusion

            var _principleConclusion1 = new GCPrincipleConclusion
            {
                Id = _principleSummary1.Id,
                AssessmentComments = new List<string>
                {
                    "Assessment Comment 1",
                    "Assessment Comment 2",
                    "Assessment Comment 3",
                    "Assessment Comment 4",
                    "Assessment Comment 5",
                    "Assessment Comment 6"
                },
                AssessmentSummaryAndConclusionIntroductionSentence = "Conclusion Introduction Sentence ... and some info."
            };

            var _principleConclusion2 = new GCPrincipleConclusion
            {
                Id = _principleSummary2.Id,
                AssessmentComments = new List<string>
                {
                    "Assessment Comment 1",
                    "Assessment Comment 2",
                    "Assessment Comment 3",
                    "Assessment Comment 4",
                },
                AssessmentSummaryAndConclusionIntroductionSentence = "Conclusion Introduction Sentence ... and some info."
            };

            var _principleConclusion3 = new GCPrincipleConclusion
            {
                Id = _principleSummary3.Id,
                AssessmentComments = new List<string>
                {
                    "Assessment Comment 3",
                    "Assessment Comment 4",
                    "Assessment Comment 5",
                    "Assessment Comment 6"
                },
                AssessmentSummaryAndConclusionIntroductionSentence = "Conclusion Introduction Sentence ... and some info."
            };

            _principleConclusionDocuments.AddRange(new List<GCPrincipleConclusion>
            {
                _principleConclusion1,
                _principleConclusion2,
                _principleConclusion3
            });

            #endregion

            #region GCPrincipleEventIndicator

            var _principleEventIndicator1 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.NonCompliant,
                PrincipleSummaryId = _principleSummary2.Id,
                IssueType = "Issue Type ... and other info."
            };

            var _principleEventIndicator2 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.NonCompliant,
                PrincipleSummaryId = _principleSummary2.Id,
                IssueType = "Issue Type ... and other info."
            };

            var _principleEventIndicator3 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.NonCompliant,
                PrincipleSummaryId = _principleSummary3.Id,
                IssueType = "Issue Type ... and other info."
            };

            var _principleEventIndicator4 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.NonCompliant,
                PrincipleSummaryId = _principleSummary3.Id,
                IssueType = "Issue Type ... and other info."
            };

            var _principleEventIndicator5 = new GCPrincipleEventIndicator
            {
                Id = Guid.NewGuid(),
                EventSummary = "Event Summary ... and other info.",
                EventIndicatorAssessment = GCAssessment.NonCompliant,
                PrincipleSummaryId = _principleSummary1.Id,
                IssueType = "Issue Type ... and other info."
            };

            _principleEventIndicatorDocuments.AddRange(new List<GCPrincipleEventIndicator>
            {
                _principleEventIndicator1,
                _principleEventIndicator2,
                _principleEventIndicator3,
                _principleEventIndicator4,
                _principleEventIndicator5
            });

            #endregion

            #region GCPrincipleEventIndicatorImpact

            var _principleEventIndicatorImpact1 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact1.LoadFrom(_principleEventIndicator1);
            _principleEventIndicatorImpact1.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact1.ImpactComments = new List<string>
            {
                "Impact Comment 1",
                "Impact Comment 2",
                "Impact Comment 3",
                "Impact Comment 4",
                "Impact Comment 5"
            };

            var _principleEventIndicatorImpact2 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact2.LoadFrom(_principleEventIndicator2);
            _principleEventIndicatorImpact2.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact2.ImpactComments = new List<string>
            {
                "Impact Comment 1",
                "Impact Comment 5"
            };

            var _principleEventIndicatorImpact3 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact3.LoadFrom(_principleEventIndicator3);
            _principleEventIndicatorImpact3.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact3.ImpactComments = new List<string>
            {
                "Impact Comment 1",
                "Impact Comment 2",
                "Impact Comment 5"
            };

            var _principleEventIndicatorImpact4 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact4.LoadFrom(_principleEventIndicator4);
            _principleEventIndicatorImpact4.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact4.ImpactComments = new List<string>
            {
                "Impact Comment 3",
                "Impact Comment 4",
                "Impact Comment 5"
            };

            var _principleEventIndicatorImpact5 = new GCPrincipleEventIndicatorImpact();
            _principleEventIndicatorImpact5.LoadFrom(_principleEventIndicator5);
            _principleEventIndicatorImpact5.ImpactSummary = "Impact Summary ... and other info.";
            _principleEventIndicatorImpact5.ImpactComments = new List<string>
            {
                "Impact Comment 1",
                "Impact Comment 2",
                "Impact Comment 3"
            };

            _principleEventIndicatorImpactDocuments.AddRange(new List<GCPrincipleEventIndicatorImpact>
            {
                _principleEventIndicatorImpact1,
                _principleEventIndicatorImpact2,
                _principleEventIndicatorImpact3,
                _principleEventIndicatorImpact4,
                _principleEventIndicatorImpact5
            });

            #endregion

            #region GCPrincipleEventIndicatorManagement

            var _principleEventIndicatorManagement1 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement1.LoadFrom(_principleEventIndicator1);
            _principleEventIndicatorManagement1.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement1.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            var _principleEventIndicatorManagement2 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement2.LoadFrom(_principleEventIndicator2);
            _principleEventIndicatorManagement2.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement2.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            var _principleEventIndicatorManagement3 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement3.LoadFrom(_principleEventIndicator3);
            _principleEventIndicatorManagement3.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement3.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            var _principleEventIndicatorManagement4 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement4.LoadFrom(_principleEventIndicator4);
            _principleEventIndicatorManagement4.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement4.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            var _principleEventIndicatorManagement5 = new GCPrincipleEventIndicatorManagement();
            _principleEventIndicatorManagement5.LoadFrom(_principleEventIndicator5);
            _principleEventIndicatorManagement5.ManagementSummary = "Management Summary ... and other info.";
            _principleEventIndicatorManagement5.ManagementComments = new List<string>
            {
                "Management Comment 1",
                "Management Comment 2",
                "Management Comment 3",
                "Management Comment 4",
                "Management Comment 5"
            };

            _principleEventIndicatorManagementDocuments.AddRange(new List<GCPrincipleEventIndicatorManagement>
            {
                _principleEventIndicatorManagement1,
                _principleEventIndicatorManagement2,
                _principleEventIndicatorManagement3,
                _principleEventIndicatorManagement4,
                _principleEventIndicatorManagement5
            });

            #endregion
        }

        private void PopulateDb()
        {
            _repository.SaveGcOverallCompanySummary(_overallCompanySummaryDocuments);
            _repository.SaveGcOverallCompanyExtended(_overallCompanySummaryExtendedDocuments);
            _repository.SaveGCPrincipleSummary(_principleSummaryDocuments);
            _repository.SaveGcPrincipleConclusion(_principleConclusionDocuments);
            _repository.SaveGCPrincipleEventIndicator(_principleEventIndicatorDocuments);
            _repository.SaveGCPrincipleEventIndicatorImpact(_principleEventIndicatorImpactDocuments);
            _repository.SaveGCPrincipleEventIndicatorManagement(_principleEventIndicatorManagementDocuments);
        }

        [TestInitialize]
        public void Initialize()
        {
            _repository = ClientDWGlobalCompactRepository.GetInstance(ConnectionString);

            var url = MongoUrl.Create(ConnectionString);

            if (string.IsNullOrWhiteSpace(url.DatabaseName))
                throw new ArgumentException("No database specified in the connection string!");

            var client = new MongoClient(url);

            _database = client.GetDatabase(url.DatabaseName);

            _repository.Cleanup();
            SetupFake_Common();
            SetupFake_Company_Compliant();
            SetupFake_Company_Watchlist();
            SetupFake_Company_NonCompliant();
            SetupFake_Company_NonCompliant_NoWatchlistIndicators();
        }

        [TestCleanup]
        public void TestCleanup()
        {
            _repository.Cleanup();
        }

        #region GCOverallCompanySummaryExtended

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedCount_OverallAssessmentNull_Success()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            //if assessment parameter is null we get only NC and WL assessments
            int expectedValue = _overallCompanySummaryDocuments.Where(el => el.UniverseIds.Any(u => expectedUniverses.Contains(u) && el.OverallCompanyAssessment != GCAssessment.Compliant)).Count();

            int value = _repository.GetGCOverallCompanySummaryExtendedCount(null, expectedUniverses, null);

            Assert.IsTrue(expectedValue == value, "Returned value is not the same as expected.");
        }

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedCount_OverallAssessmentCompliant_Success()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            int expectedValue = _overallCompanySummaryDocuments.Where(el => el.OverallCompanyAssessment == GCAssessment.Compliant
                && el.UniverseIds.Any(u => expectedUniverses.Contains(u))).Count();

            int value = _repository.GetGCOverallCompanySummaryExtendedCount(null, expectedUniverses, GCAssessment.Compliant);

            Assert.IsTrue(expectedValue == value, "Returned value is not the same as expected.");
        }

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedCount_OverallAssessmentNonCompliant_Success()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            int expectedValue = _overallCompanySummaryDocuments.Where(el => el.OverallCompanyAssessment == GCAssessment.NonCompliant
                && el.UniverseIds.Any(u => expectedUniverses.Contains(u))).Count();

            int value = _repository.GetGCOverallCompanySummaryExtendedCount(null, expectedUniverses, GCAssessment.NonCompliant);

            Assert.IsTrue(expectedValue == value, "Returned value is not the same as expected.");
        }

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedCount_OverallAssessmentWatchlist_Success()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            int expectedValue = _overallCompanySummaryDocuments.Where(el => el.OverallCompanyAssessment == GCAssessment.Watchlist
                && el.UniverseIds.Any(u => expectedUniverses.Contains(u))).Count();

            int value = _repository.GetGCOverallCompanySummaryExtendedCount(null, expectedUniverses, GCAssessment.Watchlist);

            Assert.IsTrue(expectedValue == value, "Returned value is not the same as expected.");
        }

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedList_OverallAssessmentNull_Success()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            //if assessment parameter is null we get only NC and WL assessments
            List<GCOverallCompanySummaryExtended> expectedValue = _overallCompanySummaryExtendedDocuments
                .Where(el => el.UniverseIds.Any(u => expectedUniverses.Contains(u)) && el.OverallCompanyAssessment != GCAssessment.Compliant).ToList();

            List<GCOverallCompanySummaryExtended> value = _repository.GetGCOverallCompanySummaryExtendedList(null, expectedUniverses, null, null, null, null, true);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(expectedValue.Select(el => el.Id).SequenceEqual(value.Select(el => el.Id)));
        }

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedList_OverallAssessmentCompliant_Success()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            List<GCOverallCompanySummaryExtended> expectedValue = _overallCompanySummaryExtendedDocuments
                .Where(el => el.OverallCompanyAssessment == GCAssessment.Compliant
                    && el.UniverseIds.Any(u => expectedUniverses.Contains(u))).ToList();

            List<GCOverallCompanySummaryExtended> value = _repository.GetGCOverallCompanySummaryExtendedList(null, expectedUniverses, GCAssessment.Compliant, null, null, null, true);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(expectedValue.Select(el => el.Id).SequenceEqual(value.Select(el => el.Id)));
        }

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedList_OverallAssessmentNonCompliant_Success()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            List<GCOverallCompanySummaryExtended> expectedValue = _overallCompanySummaryExtendedDocuments
                .Where(el => el.OverallCompanyAssessment == GCAssessment.NonCompliant
                    && el.UniverseIds.Any(u => expectedUniverses.Contains(u))).ToList();

            List<GCOverallCompanySummaryExtended> value = _repository.GetGCOverallCompanySummaryExtendedList(null, expectedUniverses, GCAssessment.NonCompliant, null, null, null, true);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(expectedValue.Select(el => el.Id).SequenceEqual(value.Select(el => el.Id)));
        }

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedList_OverallAssessmentWatchlist_Success()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            List<GCOverallCompanySummaryExtended> expectedValue = _overallCompanySummaryExtendedDocuments
                .Where(el => el.OverallCompanyAssessment == GCAssessment.Watchlist
                    && el.UniverseIds.Any(u => expectedUniverses.Contains(u))).ToList();

            List<GCOverallCompanySummaryExtended> value = _repository.GetGCOverallCompanySummaryExtendedList(null, expectedUniverses, GCAssessment.Watchlist, null, null, null, true);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(expectedValue.Select(el => el.Id).SequenceEqual(value.Select(el => el.Id)));
        }

        //testing filters

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedCount_FilterByCompanyName_Industry_NullOverallAssessment()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            GCOverallCompanySummaryExtendedFilters filters = new GCOverallCompanySummaryExtendedFilters()
            {
                CompanyNameLowerCase = "a&d company, limited",
                Industry = "IndustryA",
                OverallAssessmentFilter = null,
                PrinciplesNCStrFilter = null,
                PrinciplesWLStrFilter = null
            };

            //if assessment parameter is null we get only NC and WL assessments
            List<GCOverallCompanySummaryExtended> expectedCollection = _overallCompanySummaryExtendedDocuments.Where(el =>
                      el.UniverseIds.Any(u => expectedUniverses.Contains(u))
                   && el.OverallCompanyAssessment != GCAssessment.Compliant
                   && el.CompanyProfile.NameLowercase.Contains(filters.CompanyNameLowerCase.ToLowerInvariant())
                   && el.CompanyProfile.Industry.ToLowerInvariant().Contains(filters.Industry.ToLowerInvariant())).ToList();

            int expectedCount = expectedCollection.Count();

            int actualCount = _repository.GetGCOverallCompanySummaryExtendedCount(filters, expectedUniverses, null);
            List<GCOverallCompanySummaryExtended> actualCollection = _repository.GetGCOverallCompanySummaryExtendedList(filters, expectedUniverses, null, null, null, null, true);

            Assert.IsTrue(expectedCount == actualCount, "Returned value is not the same as expected.");
            Assert.IsTrue(expectedCollection.Select(el => el.Id).SequenceEqual(actualCollection.Select(el => el.Id)));
        }

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedCount_FilterByCompanyName_Industry_OverallAssessment()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            GCOverallCompanySummaryExtendedFilters filters = new GCOverallCompanySummaryExtendedFilters()
            {
                CompanyNameLowerCase = "a&d company, limited",
                Industry = "IndustryA",
                OverallAssessmentFilter = GCAssessment.NonCompliant,
                PrinciplesNCStrFilter = null,
                PrinciplesWLStrFilter = null
            };

            //if assessment parameter is null we get only NC and WL assessments
            List<GCOverallCompanySummaryExtended> expectedCollection = _overallCompanySummaryExtendedDocuments.Where(el =>
                      el.UniverseIds.Any(u => expectedUniverses.Contains(u))
                   && el.OverallCompanyAssessment == GCAssessment.NonCompliant
                   && el.CompanyProfile.NameLowercase.Contains(filters.CompanyNameLowerCase)
                   && el.CompanyProfile.Industry.ToLowerInvariant().Contains(filters.Industry.ToLowerInvariant())).ToList();

            int expectedCount = expectedCollection.Count();

            int actualCount = _repository.GetGCOverallCompanySummaryExtendedCount(filters, expectedUniverses, null);
            List<GCOverallCompanySummaryExtended> actualCollection = _repository.GetGCOverallCompanySummaryExtendedList(filters, expectedUniverses, null, null, null, null, true);

            Assert.IsTrue(expectedCount == actualCount, "Returned value is not the same as expected.");
            Assert.IsTrue(expectedCollection.Select(el => el.Id).SequenceEqual(actualCollection.Select(el => el.Id)));
        }

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedCount_FilterBy_PrinciplesNC_And_PrinciplesWL_NoNA()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            GCOverallCompanySummaryExtendedFilters filters = new GCOverallCompanySummaryExtendedFilters()
            {
                CompanyNameLowerCase = null,
                Industry = null,
                OverallAssessmentFilter = null,
                PrinciplesNCStrFilter = "1|3",
                PrinciplesWLStrFilter = "4|5"
            };

            var pNCArray = filters.PrinciplesNCStrFilter.Split('|');
            var pWLArray = filters.PrinciplesWLStrFilter.Split('|');

            //if assessment parameter is null we get only NC and WL assessments
            List<GCOverallCompanySummaryExtended> expectedCollection = _overallCompanySummaryExtendedDocuments.Where(el =>
                      el.UniverseIds.Any(u => expectedUniverses.Contains(u))
                   && el.OverallCompanyAssessment != GCAssessment.Compliant
                   && pNCArray.ContainsAny(el.NonCompliantPrinciples.Select(t => t.Id.ToString()))
                   && pWLArray.ContainsAny(el.WatchListPrinciples.Select(t => t.Id.ToString()))
                   ).ToList();

            int expectedCount = expectedCollection.Count();

            int actualCount = _repository.GetGCOverallCompanySummaryExtendedCount(filters, expectedUniverses, null);
            List<GCOverallCompanySummaryExtended> actualCollection = _repository.GetGCOverallCompanySummaryExtendedList(filters, expectedUniverses, null, null, null, null, true);

            Assert.IsTrue(expectedCount == actualCount, "Returned value is not the same as expected.");
            Assert.IsTrue(expectedCollection.Select(el => el.Id).SequenceEqual(actualCollection.Select(el => el.Id)));
        }

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedCount_FilterBy_PrinciplesNC_With_NA()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            GCOverallCompanySummaryExtendedFilters filters = new GCOverallCompanySummaryExtendedFilters()
            {
                CompanyNameLowerCase = null,
                Industry = null,
                OverallAssessmentFilter = null,
                PrinciplesNCStrFilter = "0",
                PrinciplesWLStrFilter = null
            };

            var pNCArray = filters.PrinciplesNCStrFilter.Split('|');

            //if assessment parameter is null we get only NC and WL assessments

            Expression<Func<GCOverallCompanySummaryExtended, bool>> predicate = c => true;

            predicate = predicate.And(el => el.UniverseIds.Any(u => expectedUniverses.Contains(u)));
            predicate = predicate.And(el => el.OverallCompanyAssessment != GCAssessment.Compliant);

            if (pNCArray.Any(x => x != "0"))
            {
                var ncArrFlt = pNCArray.Where(x => x != "0");
                predicate = predicate.And(x => ncArrFlt.ContainsAny(x.NonCompliantPrinciples.Select(t => t.Id.ToString())));
            }

            //if we have  N/A
            if (pNCArray.Any(x => x == "0"))
            {
                if (pNCArray.Count() > 1)
                {
                    predicate = predicate.Or(x => !x.NonCompliantPrinciples.Any());
                }
                else
                {
                    predicate = predicate.And(x => !x.NonCompliantPrinciples.Any());
                }
            }

            int expectedCount = _overallCompanySummaryExtendedDocuments.Where(predicate.Compile()).Count();
            List<GCOverallCompanySummaryExtended> expectedCollection = _overallCompanySummaryExtendedDocuments.Where(predicate.Compile()).ToList();

            int actualCount = _repository.GetGCOverallCompanySummaryExtendedCount(filters, expectedUniverses, null);
            List<GCOverallCompanySummaryExtended> actualCollection = _repository.GetGCOverallCompanySummaryExtendedList(filters, expectedUniverses, null, null, null, null, true);

            Assert.IsTrue(expectedCount == actualCount, "Returned value is not the same as expected.");
            Assert.IsTrue(expectedCollection.Select(el => el.Id).SequenceEqual(actualCollection.Select(el => el.Id)));
        }

        [TestMethod]
        public void GCOverallCompanySummaryExtended_GetGCOverallCompanySummaryExtendedCount_FilterBy_PrinciplesWL_With_NA()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            GCOverallCompanySummaryExtendedFilters filters = new GCOverallCompanySummaryExtendedFilters()
            {
                CompanyNameLowerCase = null,
                Industry = null,
                OverallAssessmentFilter = null,
                PrinciplesNCStrFilter = null,
                PrinciplesWLStrFilter = "0"
            };

            var pWLArray = filters.PrinciplesWLStrFilter.Split('|');

            //if assessment parameter is null we get only NC and WL assessments

            Expression<Func<GCOverallCompanySummaryExtended, bool>> predicate = c => true;

            predicate = predicate.And(el => el.UniverseIds.Any(u => expectedUniverses.Contains(u)));
            predicate = predicate.And(el => el.OverallCompanyAssessment != GCAssessment.Compliant);

            if (pWLArray.Any(x => x != "0"))
            {
                var ncArrFlt = pWLArray.Where(x => x != "0");
                predicate = predicate.And(x => ncArrFlt.ContainsAny(x.WatchListPrinciples.Select(t => t.Id.ToString())));
            }

            //if we have  N/A
            if (pWLArray.Any(x => x == "0"))
            {
                if (pWLArray.Count() > 1)
                {
                    predicate = predicate.Or(x => !x.WatchListPrinciples.Any());
                }
                else
                {
                    predicate = predicate.And(x => !x.WatchListPrinciples.Any());
                }
            }

            int expectedCount = _overallCompanySummaryExtendedDocuments.Where(predicate.Compile()).Count();
            List<GCOverallCompanySummaryExtended> expectedCollection = _overallCompanySummaryExtendedDocuments.Where(predicate.Compile()).ToList();

            int actualCount = _repository.GetGCOverallCompanySummaryExtendedCount(filters, expectedUniverses, null);
            List<GCOverallCompanySummaryExtended> actualCollection = _repository.GetGCOverallCompanySummaryExtendedList(filters, expectedUniverses, null, null, null, null, true);

            Assert.IsTrue(expectedCount == actualCount, "Returned value is not the same as expected.");
            Assert.IsTrue(expectedCollection.Select(el => el.Id).SequenceEqual(actualCollection.Select(el => el.Id)));
        }

        //end testing filters

        #endregion

        #region GCOverallCompanySummary

        [TestMethod]
        public void GCOverallCompanySummary_Get_ByCompany_NotFound_Success()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            GCOverallCompanySummary value = _repository.GetGCOverallCompanySummaryByCompany(expectedUniverses, Guid.NewGuid(), null);

            Assert.IsNull(value);
        }

        [TestMethod]
        public void GCOverallCompanySummary_Get_ByCompany_OverallAssessmentNull_Success()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            GCOverallCompanySummary expectedValue = _overallCompanySummaryDocuments.Where(el => el.UniverseIds.Any(u => expectedUniverses.Contains(u))).First();

            GCOverallCompanySummary value = _repository.GetGCOverallCompanySummaryByCompany(expectedUniverses, expectedValue.CompanyProfile.Id, null);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(value.Id == expectedValue.Id, "Returned value is different than the expected value.");
        }

        [TestMethod]
        public void GCOverallCompanySummary_Get_ByCompany_OverallAssessmentNotNull_Success()
        {
            PopulateDb();

            List<int> expectedUniverses = new List<int> { 1, 3, 5 };

            GCOverallCompanySummary expectedValue = _overallCompanySummaryDocuments.Where(el => el.UniverseIds.Any(u => expectedUniverses.Contains(u))).First();

            GCOverallCompanySummary value = _repository.GetGCOverallCompanySummaryByCompany(expectedUniverses, expectedValue.CompanyProfile.Id, expectedValue.OverallCompanyAssessment);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(value.Id == expectedValue.Id, "Returned value is different than the expected value.");
        }

        #endregion

        #region GCPrincipleConclusion

        [TestMethod]
        public void GCPrincipleConclusion_GetGCPrincipleConclusionByPrincipleSummary_NotFound_Success()
        {
            PopulateDb();

            GCPrincipleConclusion value = _repository.GetGCPrincipleConclusionByPrincipleSummary(Guid.NewGuid());

            Assert.IsNull(value, "Returned value is not null.");
        }

        [TestMethod]
        public void GCPrincipleConclusion_GetGCPrincipleConclusionByPrincipleSummary_Success()
        {
            PopulateDb();

            GCPrincipleConclusion expectedValue = _principleConclusionDocuments.FirstOrDefault();

            GCPrincipleConclusion value = _repository.GetGCPrincipleConclusionByPrincipleSummary(expectedValue.Id);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(expectedValue.Id == value.Id, "Returned value is different than the expected value.");
        }

        #endregion

        #region GCPrincipleEventIndicatorImpact

        [TestMethod]
        public void GCPrincipleEventIndicatorImpact_Get_NotFound_Success()
        {
            PopulateDb();

            List<GCPrincipleEventIndicatorImpact> value = _repository.GetGCPrincipleEventIndicatorImpactList(Guid.NewGuid());

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(value.Count == 0, "Returned list is not empty.");
        }

        [TestMethod]
        public void GetGCPrincipleEventIndicatorImpactList_Get_Success()
        {
            PopulateDb();

            Guid principleSummaryId = _principleSummaryDocuments.First().Id;

            List<GCPrincipleEventIndicatorImpact> expectedValue =
                _principleEventIndicatorImpactDocuments
                .Where(el => el.PrincipleSummaryId == principleSummaryId)
                .OrderBy(el => el.IssueType)
                .ToList();

            List<GCPrincipleEventIndicatorImpact> value = _repository.GetGCPrincipleEventIndicatorImpactList(principleSummaryId);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(expectedValue.Select(el => el.Id).SequenceEqual(value.Select(el => el.Id)), "Returned value is different than the expected.");
        }

        #endregion

        #region GCPrincipleEventIndicator

        [TestMethod]
        public void GCPrincipleEventIndicator_GetGCPrincipleEventIndicatorList_Success()
        {
            PopulateDb();

            Guid principleSummaryId = _principleSummaryDocuments.First().Id;

            List<GCPrincipleEventIndicator> expectedValue =
                _principleEventIndicatorDocuments
                .Where(el => el.PrincipleSummaryId == principleSummaryId)
                .OrderBy(el => el.IssueType)
                .ToList();

            List<GCPrincipleEventIndicator> value = _repository.GetGCPrincipleEventIndicatorList(principleSummaryId);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(expectedValue.Select(el => el.Id).SequenceEqual(value.Select(el => el.Id)), "Returned value is different than expected.");
        }

        [TestMethod]
        public void GCPrincipleEventIndicator_GetGCPrincipleEventIndicatorList_NotFound_Success()
        {
            PopulateDb();

            List<GCPrincipleEventIndicator> value = _repository.GetGCPrincipleEventIndicatorList(Guid.NewGuid());

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(value.Count == 0, "Returned list is not empty.");
        }

        #endregion

        #region GCPrincipleEventIndicatorManagement

        [TestMethod]
        public void GCPrincipleEventIndicatorManagement_GetGCPrincipleEventIndicatorManagementList_NotFound_Success()
        {
            PopulateDb();

            List<GCPrincipleEventIndicatorManagement> value = _repository.GetGCPrincipleEventIndicatorManagementList(Guid.NewGuid());

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(value.Count == 0, "Returned list is not empty.");
        }

        [TestMethod]
        public void GCPrincipleEventIndicatorManagement_GetGCPrincipleEventIndicatorManagementList_Success()
        {
            PopulateDb();

            Guid principleSummaryId = _principleSummaryDocuments.First().Id;

            List<GCPrincipleEventIndicatorManagement> expectedValue = _principleEventIndicatorManagementDocuments
                .Where(el => el.PrincipleSummaryId == principleSummaryId)
                .OrderBy(el => el.IssueType)
                .ToList();

            List<GCPrincipleEventIndicatorManagement> value = _repository.GetGCPrincipleEventIndicatorManagementList(principleSummaryId);

            Assert.IsNotNull(value, "Returned value is not null.");
            Assert.IsTrue(value.Select(el => el.Id).SequenceEqual(expectedValue.Select(el => el.Id)), "Returned value is different than expected.");
        }

        #endregion

        #region GCPrincipleSummary

        [TestMethod]
        public void GCPrincipleSummary_GetGCPrincipleSummaryList_NotFound_Success()
        {
            PopulateDb();

            List<GCPrincipleSummary> value = _repository.GetGCPrincipleSummaryList(Guid.NewGuid(), null);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(value.Count == 0, "Returned list is not empty.");
        }

        [TestMethod]
        public void GCPrincipleSummary_GetGCPrincipleSummaryList_OverallAssessmentNull_Success()
        {
            PopulateDb();

            Guid companyId = _overallCompanySummaryDocuments.First().CompanyProfile.Id;

            List<GCPrincipleSummary> expectedValue =
                _principleSummaryDocuments
                .Where(el => el.CompanyId == companyId)
                .OrderBy(el => el.Principle.Name)
                .ToList();

            List<GCPrincipleSummary> value = _repository.GetGCPrincipleSummaryList(companyId, null);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(expectedValue.Select(el => el.Id).SequenceEqual(value.Select(el => el.Id)), "Returned value is different than expected.");
        }

        [TestMethod]
        public void GCPrincipleSummary_GetGCPrincipleSummaryList_OverallAssessmentCompliant_Success()
        {
            PopulateDb();

            Guid companyId = _overallCompanySummaryDocuments.First().CompanyProfile.Id;

            List<GCPrincipleSummary> expectedValue =
                _principleSummaryDocuments
                .Where(el => el.CompanyId == companyId && el.PrincipleAssessment == GCAssessment.Compliant)
                .OrderBy(el => el.Principle.Name)
                .ToList();

            List<GCPrincipleSummary> value = _repository.GetGCPrincipleSummaryList(companyId, GCAssessment.Compliant);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(expectedValue.Select(el => el.Id).SequenceEqual(value.Select(el => el.Id)), "Returned value is different than expected.");
        }

        [TestMethod]
        public void GCPrincipleSummary_GetGCPrincipleSummaryList_OverallAssessmentNonCompliant_Success()
        {
            PopulateDb();

            Guid companyId = _overallCompanySummaryDocuments.First().CompanyProfile.Id;

            List<GCPrincipleSummary> expectedValue =
                _principleSummaryDocuments
                .Where(el => el.CompanyId == companyId && el.PrincipleAssessment == GCAssessment.NonCompliant)
                .OrderBy(el => el.Principle.Name)
                .ToList();

            List<GCPrincipleSummary> value = _repository.GetGCPrincipleSummaryList(companyId, GCAssessment.NonCompliant);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(expectedValue.Select(el => el.Id).SequenceEqual(value.Select(el => el.Id)), "Returned value is different than expected.");
        }

        [TestMethod]
        public void GCPrincipleSummary_GetGCPrincipleSummaryList_OverallAssessmentWatchlist_Success()
        {
            PopulateDb();

            Guid companyId = _overallCompanySummaryDocuments.First().CompanyProfile.Id;

            List<GCPrincipleSummary> expectedValue =
                _principleSummaryDocuments
                .Where(el => el.CompanyId == companyId && el.PrincipleAssessment == GCAssessment.Watchlist)
                .OrderBy(el => el.Principle.Name)
                .ToList();

            List<GCPrincipleSummary> value = _repository.GetGCPrincipleSummaryList(companyId, GCAssessment.Watchlist);

            Assert.IsNotNull(value, "Returned value is null.");
            Assert.IsTrue(expectedValue.Select(el => el.Id).SequenceEqual(value.Select(el => el.Id)), "Returned value is different than expected.");
        }

        #endregion

        #region Save

        [TestMethod]
        public void SaveGCOverallCompanySummaryTest()
        {
            _repository.SaveGcOverallCompanySummary(_overallCompanySummaryDocuments);

            var collection = _database.GetCollection<GCOverallCompanySummary>(typeof(GCOverallCompanySummary).Name)
                                      .AsQueryable()
                                      .ToList()
                                      .OrderBy(el => el.Id)
                                      .ToList();

            var expectedValue = _overallCompanySummaryDocuments.OrderBy(el => el.Id).ToList();

            Assert.IsTrue(expectedValue.OrderBy(el => el.Id).SequenceEqual(collection, new GCOverallCompanySummary()));
        }

        [TestMethod]
        public void SaveGCOverallCompanySummaryExtendedTest()
        {
            _repository.SaveGcOverallCompanyExtended(_overallCompanySummaryExtendedDocuments);

            var collection = _database.GetCollection<GCOverallCompanySummaryExtended>(typeof(GCOverallCompanySummaryExtended).Name)
                                      .AsQueryable()
                                      .ToList()
                                      .OrderBy(el => el.Id)
                                      .ToList();

            var expectedValue = _overallCompanySummaryExtendedDocuments.OrderBy(el => el.Id).ToList();

            Assert.IsTrue(expectedValue.OrderBy(el => el.Id).SequenceEqual(collection, new GCOverallCompanySummaryExtended()));
        }

        [TestMethod]
        public void SaveGCPrincipleSummaryTest()
        {
            _repository.SaveGCPrincipleSummary(_principleSummaryDocuments);

            var collection = _database.GetCollection<GCPrincipleSummary>(typeof(GCPrincipleSummary).Name)
                                      .AsQueryable()
                                      .ToList()
                                      .OrderBy(el => el.Id)
                                      .ToList();

            var expectedValue = _principleSummaryDocuments.OrderBy(el => el.Id).ToList();

            Assert.IsTrue(expectedValue.OrderBy(el => el.Id).SequenceEqual(collection, new GCPrincipleSummary()));
        }

        [TestMethod]
        public void SaveGCPrincipleConclusionTest()
        {
            _repository.SaveGcPrincipleConclusion(_principleConclusionDocuments);

            var collection = _database.GetCollection<GCPrincipleConclusion>(typeof(GCPrincipleConclusion).Name)
                                      .AsQueryable()
                                      .ToList()
                                      .OrderBy(el => el.Id)
                                      .ToList();

            var expectedValue = _principleConclusionDocuments.OrderBy(el => el.Id).ToList();

            Assert.IsTrue(expectedValue.OrderBy(el => el.Id).SequenceEqual(collection, new GCPrincipleConclusion()));
        }

        [TestMethod]
        public void SaveGCPrincipleEventIndicatorTest()
        {
            _repository.SaveGCPrincipleEventIndicator(_principleEventIndicatorDocuments);

            var collection = _database.GetCollection<GCPrincipleEventIndicator>(typeof(GCPrincipleEventIndicator).Name)
                                      .AsQueryable()
                                      .ToList()
                                      .OrderBy(el => el.Id)
                                      .ToList();

            var expectedValue = _principleEventIndicatorDocuments.OrderBy(el => el.Id).ToList();

            Assert.IsTrue(expectedValue.OrderBy(el => el.Id).SequenceEqual(collection, new GCPrincipleEventIndicator()));
        }

        [TestMethod]
        public void SaveGCPrincipleEventIndicatorImpactTest()
        {
            _repository.SaveGCPrincipleEventIndicatorImpact(_principleEventIndicatorImpactDocuments);

            var collection = _database.GetCollection<GCPrincipleEventIndicatorImpact>(typeof(GCPrincipleEventIndicatorImpact).Name)
                                      .AsQueryable()
                                      .ToList()
                                      .OrderBy(el => el.Id)
                                      .ToList();

            var expectedValue = _principleEventIndicatorImpactDocuments.OrderBy(el => el.Id).ToList();

            Assert.IsTrue(expectedValue.OrderBy(el => el.Id).SequenceEqual(collection, new GCPrincipleEventIndicatorImpact()));
        }

        [TestMethod]
        public void SaveGCPrincipleEventIndicatorManagementTest()
        {
            _repository.SaveGCPrincipleEventIndicatorManagement(_principleEventIndicatorManagementDocuments);

            var collection = _database.GetCollection<GCPrincipleEventIndicatorManagement>(typeof(GCPrincipleEventIndicatorManagement).Name)
                                      .AsQueryable()
                                      .ToList()
                                      .OrderBy(el => el.Id)
                                      .ToList();

            var expectedValue = _principleEventIndicatorManagementDocuments.OrderBy(el => el.Id).ToList();

            Assert.IsTrue(expectedValue.OrderBy(el => el.Id).SequenceEqual(collection, new GCPrincipleEventIndicatorManagement()));
        }

        #endregion Save
    }
}
